package com.lucker.common.util;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;

import com.lucker.common.request.RequestHeader;

public class RequestUtil {
	
	
	public static RequestHeader getReqeustHeader(HttpServletRequest request) {
		
		RequestHeader requestHeader = new RequestHeader();
		
		if(StringUtils.isNotBlank(request.getHeader("appVersion"))) {
			requestHeader.setAppVersion(request.getHeader("appVersion"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("traderName"))) {
			requestHeader.setTraderName(request.getHeader("traderName"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("appType"))) {
			requestHeader.setAppType(request.getHeader("appType"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("clientVersion"))) {
			requestHeader.setClientVersion(request.getHeader("clientVersion"));
		}
		
		
		if(StringUtils.isNotBlank(request.getHeader("deviceCode"))) {
			requestHeader.setDeviceCode(request.getHeader("deviceCode"));
		}
		
		
		if(StringUtils.isNotBlank(request.getHeader("channel"))) {
			requestHeader.setChannel(request.getHeader("channel"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("caiId"))) {
			requestHeader.setCaiId(request.getHeader("caiId"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("caiType"))) {
			requestHeader.setCaiType(request.getHeader("caiType"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("userToken"))) {
			requestHeader.setUserToken(request.getHeader("userToken"));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("userId"))) {
			requestHeader.setUserId(Long.valueOf(request.getHeader("userId")));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("timestamp"))) {
			requestHeader.setTimestamp(Long.valueOf(request.getHeader("timestamp")));
		}
		
		if(StringUtils.isNotBlank(request.getHeader("signature"))) {
			requestHeader.setSignature(request.getHeader("signature"));
		}
		
		return requestHeader;
		
	}

	
	
}
